<?php require_once 'header.php';?>    <!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <?php echo XXF_LNAME?>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                        	<input type="hidden" id="lnum" name="x" value="0">
                        	<input type="hidden" id="uid" name="x" value="<?php echo XXF_UID?>">
                        	<input type="hidden" id="ntype" name="x" value="普通信息">
                    		<input placeholder="标题"  name="x" id="ntitle" type="text" class="form-control" style="width: 300px">
                    		<textarea id="ncontent" name="x" style="width:100%;height:200px;visibility:hidden;">&nbsp;</textarea>
                    		<input class="btn btn-sm btn-info"  type="button" id="sub" value="提交" onclick="sub()">
                        <hr>
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>标题</th>
                                        <th>点击</th>
                                        <th>类型</th>
                                        <th>时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA">
                                        <td><?php echo $i+1;?></td>
                                        <td><?php echo $row['ntitle'];?></td>
                                        <td><?php echo $row['lnum'];?></td>
                                        <td><?php echo $row['ntype'];?></td>
                                        <td><?php echo $row['atime'];?></td>
                                        <td>
                                        	<a href="javascript:del(<?php echo $row['id']?>)">删除</a> | 
                                        	<a href="javascript:upd(<?php echo $row['id']?>)">修改</a>
                                        </td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script charset="utf-8" src="kindeditor/kindeditor-all.js?r=<?php echo rand()?>"></script>
	<script>
	var editor1;
	KindEditor.ready(function(K) {
		editor1 = K.create('textarea[name="x"]', {
			resizeType : 1,
			allowPreviewEmoticons : false,
			items : [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
                'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap'
            ]
		});
	});
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "asc" ]]
        });
    });
    function sub(){
        var ntitle=$("#ntitle").val();
        if(ntitle.length<1){
			$.xalert("标题不能为空！");
			return;
        }
        editor1.sync();
		$.xtodb("add","news",$("[name='x']"),"uid_ntitle_ntype_lnum",function(data){
			if(data==1){
				alert("添加成功！");
				history.go(0);
			}else{
				alert("添加失败！");}
		});
    }
    function del(id){
		$.xdel("news",id);
    }
    </script>